# from util.operation_json import OperetionJson,Path


# class CookieToken(object):
#     def __init__(self):
#         self.run_method = RunMethod()
#
#     def cookie_token(self,token,cookies,method,url,request_data,headers):
#         """
#         判断cookie和token是否需要
#         :param token:
#         :param cookies:
#         :param method:
#         :param url:
#         :param request_data:
#         :param headers:
#         :return: res
#         """
#         # 发起请求，然后写入cookie和token
#         if token == 'write' or cookies == 'write':
#             res = self.run_method.run_main(method, url, request_data, headers)
#             # 写入token和cookie
#             if token == 'write' and cookies == 'write':
#                 OperationToken(res).write_token()
#                 OperationCookie(res).write_cookie()
#             # 写入token
#             elif token == 'write' and cookies != 'write':
#                 OperationToken(res).write_token()
#             # 写入cookies
#             elif token != 'write' and cookies == 'write':
#                 OperationCookie(res).write_cookie()
#
#         # 获取cookie和token，发起请求，然后写入新的cookie和token
#         elif token == 'yes_write' or cookies == 'yes_write':
#             token_value = OperetionJson(Path.path_token).get_data('token')
#             request_data['authenticity_token'] = token_value
#             cookies_value = OperetionJson(Path.path_cookie).get_data()
#             res = None
#             if token == 'yes_write' and cookies == 'yes_write':
#                 res = self.run_method.run_main(method, url, request_data, headers, cookies_value)
#                 a02 = OperationToken(res).write_token()
#                 OperationCookie(res).write_cookie()
#             elif token == 'yes_write' and cookies != 'yes_write':
#                 res = self.run_method.run_main(method, url, request_data, headers)
#                 OperationToken(res).write_token()
#             elif token != 'yes_write' and cookies == 'yes_write':
#                 res = self.run_method.run_main(method, url, request_data, headers, cookies_value)
#                 OperationCookie(res).write_cookie()
#
#         # 获取cookie和token
#         elif token == 'yes' or cookies == 'yes':
#             cookies_value = OperetionJson(Path.path_cookie).get_data()
#             res = None
#             if token == 'yes' and cookies == 'yes':
#                 token_value = OperetionJson(Path.path_token).get_data('token')
#                 request_data['authenticity_token'] = token_value
#                 res = self.run_method.run_main(method, url, request_data, headers, cookies_value)
#             elif token == 'yes' and cookies != 'yes':
#                 token_value = OperetionJson(Path.path_token).get_data('token')
#                 request_data['authenticity_token'] = token_value
#                 res = self.run_method.run_main(method, url, request_data, headers)
#             elif token != 'yes' and cookies == 'yes':
#                 res = self.run_method.run_main(method, url, request_data, headers, cookies_value)
#         else:
#             res = self.run_method.run_main(method, url, request_data, headers)
#         return res